package 寒假刷题;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class 两句话中的不常见单词 {
    public String[] uncommonFromSentences(String s1, String s2) {
        List<String> list = new ArrayList<>();
        HashMap<String, Integer> map = new HashMap<>();
        String[] s3 = (s1 + " " + s2).split(" ");
        for (String s4 : s3) {
            map.put(s4,map.getOrDefault(s4,0)+1);
        }
        for (String s4 : map.keySet()) {
            if (map.get(s4)==1)
                list.add(s4);
        }
        String[] strings = new String[list.size()];
        return list.toArray(strings);
    }
}
